package com.example.thridhero.waterfalltest;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by thridHero on 2017/3/21.
 */

public class WomanAdapter extends RecyclerView.Adapter<WomanAdapter.ViewHolder>{

    private List<Woman> womanList;
    public WomanAdapter(List<Woman> women){
        womanList = women;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView womanImage;
        TextView womanText;

        public ViewHolder(View itemView) {
            super(itemView);
            womanImage = (ImageView) itemView.findViewById(R.id.woman_image);
            womanText = (TextView) itemView.findViewById(R.id.woman_name);
        }
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.woman_item,parent,false);
        ViewHolder  viewHolder= new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        Woman woman = womanList.get(position);
        holder.womanImage.setImageResource(woman.getImage());
        holder.womanText.setText(woman.getName());
    }

    @Override
    public int getItemCount() {
        return womanList.size();
    }
}
